<%@ page language="java" import="java.util.*, org.whuims.pois.bean.*" pageEncoding="UTF-8" %>
<%@ page import="org.whuims.pois.action.result.ClusterVo" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
    <base href="<%=basePath%>">

    <title>${sessionScope.topicName} - ${tag}</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>

    <%@include file="im.jsp" %>
    <link rel="stylesheet" href="css/subPage.css"/>
    <link rel="stylesheet" href="css/pagination.css"/>
    <script type="text/javascript" src="js/jquery.pagination.js"></script>
    <style type="text/css">
        .ProgressBar {
            float: left;
            width: 60px; /* 宽度 */
            border: 1px solid #B1D632;
            padding: 1px;
            margin: 2px 10px;
        }

        .ProgressBar div {
            display: block;
            position: relative;
            background: #B1D632;
            color: #333333;
            font-size: 10px;
            height: 11px; /* 高度 */
            line-height: 11px; /* 必须和高度一致，文本才能垂直居中 */
        }

        .ProgressBar div span {
            position: absolute;
            width: 60px; /* 宽度 */
            text-align: center;
        }
    </style>

    <script type="text/javascript">
        $(function () {
            var initPagination = function () {
                num_entries = $("#hiddenresult div.result").length;
                // 创建分页
                page = 10; //!!!!!!每页个数！！！！！！
                $("#Pagination").pagination(num_entries, {
                    num_edge_entries: 2, //边缘页数
                    num_display_entries: 6, //主体页数
                    callback: pageselectCallback,
                    items_per_page: page, //每页显示1项
                    prev_text: "前一页",
                    next_text: "后一页"
                });
            }();

            function pageselectCallback(page_index, jq) {
                var max_elem = Math.min((page_index + 1) * page, num_entries);
                $("#Searchresult").empty();
                for (var i = page_index * page; i < max_elem; i++) {
                    $("#Searchresult").append(
                            $("#hiddenresult div.result:eq(" + i + ")").clone());
                }
                return false;
            }
        });
    </script>

</head>

<body>

<%
    List<ClusterVo> clusterList = (List<ClusterVo>) request.getAttribute("result");
    int max = 20;
    if (clusterList!=null){
        if (clusterList.size()>0)
            max = clusterList.get(0).getCount();
    }
    request.setAttribute("max", max);
%>
<logic:equal name="user" value="administrator">
    <div id="content" class="container">

        <%@include file="top.jsp" %>

        <div class="row">
            <%@include file="left.jsp" %>


            <div class="col-md-9" >
                <div style="padding-left:35px">
                    <div class="titlebox">
                        <div class="title">
                            <b><%=request.getAttribute("tag") %>
                            </b>
                        </div>
                    </div>
                    <div id="Searchresult">
                        分页初始化完成后这里的内容会被替换。
                    </div>
                    <div id="hiddenresult" style="display: none;">
                        <!-- 标题title -->
                        <logic:present name="result" scope="request">
                            <logic:iterate id="cluster" name="result">
                                <!-- 标题title -->
                                <div class="result">
                                    <h4>

                                        <html:link page="/logAction.do" paramId="link"
                                                   paramName="cluster" paramProperty="link" target="_blank">
                                            <logic:notEqual name="cluster" property="title"
                                                            value="">
                                                <bean:write name="cluster" property="title"
                                                            filter="true"/>
                                            </logic:notEqual>
                                            <logic:equal name="cluster" property="title" value="">暂无标题</logic:equal>
                                        </html:link>

                                        <html:link page="/newsAction.do?method=similar"
                                                   paramId="similarId" paramName="cluster"
                                                   paramProperty="id">
                                            <div class="ProgressBar">
                                                <div style="width: ${cluster.count * 100 / max }%">
                                                    <span><bean:write name="cluster" property="count"/></span>
                                                </div>
                                            </div>
                                        </html:link>
                                        <!-- 输出时间 -->
                                        &nbsp;&nbsp;
                                        <logic:notEqual name="cluster" property="crawltime" value="">
                                            [<bean:write name="cluster" property="crawltime"/>]
                                        </logic:notEqual>


                                    </h4>
                                    <!-- 输出摘要 -->
                                    <p>
                                        <bean:write name="cluster" property="abstext" filter="true"/>
                                    </p>
                                </div>
                            </logic:iterate>
                        </logic:present>
                    </div>
                    <div id="Pagination" class="pagination">
                        <!-- 这里显示分页 -->
                    </div>


                </div>
            </div>
        </div>
        <!--end of right-->
        <div class="footer">
            <%@ include file="foot.jsp" %>
        </div>
    </div>
</logic:equal>
<logic:empty name="user">
    Access Rejected! Error 404
</logic:empty>
</body>
</html>
